Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to use slim in conjunction with ejs and jst in sprockets 4 #148

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

stiller-leser
Copy link

We use slim in our rails app in conjunction with ejs and jst (file ending: *.js.jst.ejs.slim). Sprockets 4 won't recognize slim files as 'application/javascript' and hence fail when used in the above combination. I am aware that this is an edge case, but it prevents us from switching to sprockets 4.

@@ -30,6 +30,7 @@ def self._register_engine(config)
config.assets.configure do |env|
if env.respond_to?(:register_transformer) && Sprockets::VERSION.to_i > 3
env.register_mime_type 'text/slim', extensions: ['.slim', '.slim.html']#, charset: :html
env.register_mime_type 'application/javascript', extensions: ['.js.jst.ejs.slim']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be very specific and tailored for your use case, but I think that if we're going add this, then let's do it in a more general form, how about:

env.register_mime_type 'application/javascript', extensions: %w[.js.slim .jst.slim .ejs.slim]

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to do so. However I did realize that it is not working as intended. Will continue investigation and report back once solved.

Copy link
Contributor

@januszm januszm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make it more general

@januszm
Copy link
Contributor

januszm commented Sep 8, 2017

Could you also add test similar to the one we already have for html?

      asset_path = File.join(dir, 'app', 'assets', 'html', 'test.slim')
      FileUtils.mkdir_p(File.dirname(asset_path))
      File.write(asset_path, ".test\n  | hi")

of course let's add some JS instead of html

@januszm
Copy link
Contributor

januszm commented May 20, 2021

@stiller-leser I know it's been a while, are you still interested in finishing this PR or should we rather fork this and continue on new branch?

@stiller-leser
Copy link
Author

Hi @januszm,

what a blast from the past. I have since completly changed job profiles and companies as well. So I do not even know anymore why / where this was needed. You are probably better of forking this PR.

Sorry, I can't continue with this. If there is anything I can do, let me know and I will try to help out.

Best regards,
stiller-leser

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants